package com.shuoyue.ycgk.umeng.onkeyloginconfig;

import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.graphics.Color;
import android.os.Build;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;

import com.shuoyue.ycgk.Constant;
import com.shuoyue.ycgk.R;
import com.umeng.umverify.UMVerifyHelper;
import com.umeng.umverify.view.UMAuthUIConfig;

//import com.shuoyue.ycgk.ui.account.AccountLoginActivity;

/**
 * xml文件方便预览
 * 可以通过addAuthRegisterXmlConfig一次性统一添加授权页的所有自定义view
 */
public class CustomXmlConfig extends BaseUIConfig {
    Activity activity;

    public CustomXmlConfig(Activity activity, UMVerifyHelper authHelper) {
        super(activity, authHelper);
    }

    @Override
    public void configAuthPage() {
        mAuthHelper.removeAuthRegisterXmlConfig();
        mAuthHelper.removeAuthRegisterViewConfig();
        int authPageOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
        if (Build.VERSION.SDK_INT == 26) {
            authPageOrientation = ActivityInfo.SCREEN_ORIENTATION_BEHIND;
        }
//        mAuthHelper.addAuthRegisterXmlConfig(new UMAuthRegisterXmlConfig.Builder()
//                .setLayout(R.layout.activity_onkey_login_bg, new UMAbstractPnsViewDelegate() {
//                    @Override
//                    public void onViewCreated(View view) {
//                        findViewById(R.id.other_login_type).setOnClickListener(v -> {
//                            Intent pIntent = new Intent(mActivity, LoginActivity.class);
//                            mActivity.startActivity(pIntent);
//                            mActivity.finish();
//                            mAuthHelper.quitLoginPage();
//                        });
//
//                    }
//                },new UMAbstractPnsViewDelegate())
//                .build());
        View otherWay = LayoutInflater.from(mContext).inflate(R.layout.layout_login_way, null);
//        mAuthHelper.addAuthRegistViewConfig(otherWay, new UMAuthRegisterViewConfig());

        mAuthHelper.setAuthUIConfig(new UMAuthUIConfig.Builder()
                .setAppPrivacyOne("《一锤用户协议》", Constant.HOST_INTERFACE
                        + "/api/share/agreement")
//                .setAppPrivacyTwo("《百度》", "https://www.baidu.com")
                .setAppPrivacyColor(Color.parseColor("#858ca3"), Color.parseColor("#198FF6"))
                .setLogoImgPath("ic_launcher")
                .setStatusBarHidden(false)
                .setNavHidden(true)
                .setStatusBarUIFlag(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)
                .setSloganTextColor(Color.parseColor("#ff011340"))
                .setLogBtnText("本机号码一键登录")
                .setLogBtnBackgroundPath("button_bg_theme")
                .setLogBtnHeight(40)
                .setPrivacyState(true)
                .setProtocolGravity(Gravity.LEFT)
                .setPrivacyTextSize(14)
                .setPrivacyBefore("登录即同意")
                .setVendorPrivacyPrefix("《")
                .setVendorPrivacySuffix("》")
                .setLogBtnToastHidden(false)
                .setSwitchAccHidden(false)
                .setSwitchAccText("切换其他登录方式")
                .setSwitchAccTextColor(Color.parseColor("#777777"))
                .setSwitchAccTextSize(15)
                //调整位置
                .setLogoHeight(56)
                .setLogoWidth(56)
                .setLogoOffsetY(96)//logo
                .setSloganOffsetY(168)//服务商名
                .setLogBtnOffsetY(300)
                .setSwitchOffsetY(380)



//                .setNavHidden(true)
//                .setLogoHidden(true)
//                .setSloganHidden(true)
//                .setSwitchAccHidden(true)
//                .setPrivacyState(false)
//                .setCheckboxHidden(true)
//                .setLightColor(true)
//
//                .setStatusBarColor(Color.TRANSPARENT)
//                .setStatusBarUIFlag(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)
//                .setWebNavTextSize(20)
//                .setNumberSize(20)
//                .setNumberColor(Color.BLACK)
//                .setAuthPageActIn("in_activity", "out_activity")
//                .setAuthPageActOut("in_activity", "out_activity")
//                .setVendorPrivacyPrefix("《")
//                .setVendorPrivacySuffix("》")
//                .setPageBackgroundPath("page_background_color")
//                .setLogoImgPath("mytel_app_launcher")
//                .setLogBtnBackgroundPath("login_btn_bg")
//                .setScreenOrientation(authPageOrientation)
                .create());
    }
}
